const Net = require('net');
const port = 8090;
const host = 'localhost';

const client = new Net.Socket();
client.connect({ port: port, host: host }), function() {};

client.on('connect',function(){
    client.write('你好');
});
client.on('data', function(chunk) {
    console.log(`获取到服务器信息: ${chunk.toString()}.`);
    if (chunk.toString() == '请发送1') {
        client.write('已发送1');
    }else if(chunk.toString() == '好的，再见'){
        client.end()
    }else{
        client.write('你究竟要什么？');
    }
});

client.on('end', function() {
    console.log('end');
});